package com.example.config;

import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.io.ClassPathResource;

@Configuration
public class PropertyConfig {
	
	@Bean(name = "propUtil")
	public PropertiesFactoryBean propUtil() {
		PropertiesFactoryBean bean = new PropertiesFactoryBean();
		bean.setIgnoreResourceNotFound(Boolean.FALSE);
		bean.setLocations(new ClassPathResource("config/rtncode.properties"));
		return bean;
	}
	
	@Configuration
	@Profile("dev")
	@PropertySource(
		ignoreResourceNotFound = false,
		value={
			"classpath:config/dev/app_dev.properties"
		}
	)
	static class devConfiguration {
		
		/*@Bean(name = "propUtil")
		public PropertiesFactoryBean propUtil() {
			PropertiesFactoryBean bean = new PropertiesFactoryBean();
			bean.setIgnoreResourceNotFound(Boolean.FALSE);
			bean.setLocations(new ClassPathResource("config/rtncode.properties"));
			return bean;
		}*/
	}
	
	@Configuration
	@Profile("sit")
	@PropertySource(
		ignoreResourceNotFound = false,
		value={
			"classpath:config/sit/app_sit.properties"
		}
	)
	static class sitConfiguration {
		
	}
	
	@Configuration
	@Profile("uat")
	@PropertySource(
		ignoreResourceNotFound = false,
		value={
			"classpath:config/uat/app_uat.properties"
		}
	)
	static class uatConfiguration {
		
	}
	
	@Configuration
	@Profile("prod")
	@PropertySource(
		ignoreResourceNotFound = false,
		value={
			"classpath:config/prod/app_prod.properties"
		}
	)
	static class prodConfiguration {
		
	}
	
	@Configuration
	@Profile("test")
	@PropertySource(
		ignoreResourceNotFound = false,
		value={
			"classpath:config/test/app_test.properties"
		}
	)
	static class testConfiguration {
		
	}
}